/*
 *全局统一管理用户授权
 * @Author: bobo
 */
import CacheUtil from '@/utils/CryptCacheUtil'
const KEY_USER_INFO = "user_info"
var state = {
  account: "",
  name: "",
  extra: {},
};
const UserStore = {

  init() {
    let data = CacheUtil.get(KEY_USER_INFO)
    if (data != null) {
      state = data;
    }
    console.log("用户信息:", state)
  },
  flushDisk() {
    CacheUtil.save(KEY_USER_INFO, JSON.stringify(state), -1)
  },
  setUserName(name) {
    state.name = name;
  },
  getUserName() {
    return state.name;
  },
  getUserAccount() {
    return state.account;
  },
  setUserAccount(account) {
    state.account = account
  },
  setExtra(extra) {
    state.extra = extra;
  },
  getExtra() {
    return state.extra
  }
}
export {
  UserStore
}